home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / pdc / libsrc / stdlib / system0.doc < prev   
Text File  |  1990-04-06  |  3KB  |  103 lines

  1. #! rnews 11784
  2. Path: van-bc!ubc-cs!ubc-vision!uw-beaver!mit-eddie!bloom-beacon!think!ames!pasteur!ucbvax!decvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!unido!rmi!kkaempf
  3. From: kkaempf@rmi.UUCP (Klaus Kaempf)
  4. Newsgroups: comp.sys.amiga
  5. Subject: Execute()
  6. Keywords: shell, BCPL, AmigaDOS, fork(), fexec()
  7. Message-ID: <857@rmi.UUCP>
  8. Date: 22 Jan 88 15:40:47 GMT
  9. Reply-To: kkaempf@rmi.UUCP
  10. Organization: RMI Net, Aachen, W.Germany
  11. Lines: 385
  12. Posted: Fri Jan 22 16:40:47 1988
  13.  
  14. Wanna call a CLI-command in your own application? Maybe you
  15. don't have "RUN" in your "C:" directory? Or it's "PROMPT",
  16. "STACK", "CD" or the like? So forget "Execute()"! But it's
  17. one of these BCPL programs - darn!
  18.  
  19. Try this one!
  20.  
  21. This small program can be used to execute CLI-commands, even
  22. the ones that rely on the correct BCPL setup.
  23.  
  24. Two restrictions:
  25.  
  26. "System0()" must be called from a CLI-PROCESS (or SHELL or
  27. whatever). You cannot call it from WorkBench, a simple task
  28. or interrupt (argh!).
  29.  
  30. "EXECUTE" (the CLI-command) will not loop through the
  31. batchfile itself, but rather change the "cli_CurrentInput",
  32. so the shell will execute the incoming lines until "EOF" is
  33. encountered and then restore "cli_CurrentInput". So this is
  34. not a restriction, if you return to the input-loop directly
  35. after "System0()" has been called (normally true in shell
  36. program). Batchfiles called this way may be nested, but do
  37. not try to "EXECUTE" several batch-files ...
  38.  
  39. System0("Execute", seglist, "first");
  40. System0("Execute", seglist, "second");
  41. System0("Execute", seglist, "third");
  42.  
  43. ... without returning to the input-loop first.
  44.  
  45. "System0()" WON'T handle loading and unloading of the code,
  46. I/O-redirection or whatever, but this is fairly simple.
  47.  
  48. Commands should be checked in the following order:
  49.  
  50. built-in commands of the shell
  51. resident commands ("NetHand")
  52. current directory (WindowPtr = -1)
  53. path list ("CommandDir", WindowPtr = -1)
  54. "C:" (WindowPtr = 0)
  55.  
  56. As an option for shells: Try to execute it as a batchfile
  57. (current directory or "S:"), if everything else fails (but
  58. use "WindowPtr = -1" for "C:" then).
  59.  
  60. I/O-redirection should save the values of "pr_CIS" and
  61. "pr_COS", put the new ones into these fields and restore
  62. them after the command has finished. That's why "EXECUTE" is
  63. not that much impressed if you supply it with ">" or "<".
  64.  
  65. "System0()" returns the return code (register D0 or
  66. "Exit()"-parameter) of the program called (not the same as
  67. "Execute()"!), or an internal error code:
  68.  
  69. -1: process not a CLI
  70. -2: not enough memory for stack
  71.  
  72. It does not rely on some strange undocumented data
  73. structures the way Aztec's "fexec#?()" does. You do not need
  74. a special startup code to save the registers (Csh 2.04). I
  75. still have to find the command, that cannot be called this
  76. way, but you will certainly manage this. :-)
  77.  
  78. Two non-standard include files are used. "extern/exec.i"
  79. contains the "_LVO" equates for "exec", you can use
  80. "amiga.lib" instead. "extras/asm.i" provides ...
  81.  
  82. AbsExecBase equ 4
  83.  
  84. REG_SysBase equr a6
  85.  
  86. callsys macro
  87.         jsr _LVO\1(REG_SysBase)
  88.         endm
  89.  
  90. The uuencoded object file has been created using the
  91. Metacomco Macro Assembler. A new release (11.1) of this one
  92. has been announced for the ST, does anybody have further
  93. information about an Amiga-version?
  94.  
  95. multam salutem omnibus
  96.  
  97. !ralph
  98.  
  99. P.S.: If someone would be as kind as to mail me a disk with
  100. the latest version of Matt's shell for Lattice-C? Thanks!
  101.  
  102. ################
  103.